package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.HealthUserInfoMapper;
import com.ruoyi.system.domain.HealthUserInfo;
import com.ruoyi.system.service.IHealthUserInfoService;
import com.ruoyi.common.core.text.Convert;

/**
 * 提报人员信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-02-21
 */
@Service
public class HealthUserInfoServiceImpl implements IHealthUserInfoService 
{
    @Autowired
    private HealthUserInfoMapper healthUserInfoMapper;

    /**
     * 查询提报人员信息
     * 
     * @param id 提报人员信息ID
     * @return 提报人员信息
     */
    @Override
    public HealthUserInfo selectHealthUserInfoById(String id)
    {
        return healthUserInfoMapper.selectHealthUserInfoById(id);
    }

    /**
     * 查询提报人员信息列表
     * 
     * @param healthUserInfo 提报人员信息
     * @return 提报人员信息
     */
    @Override
    public List<HealthUserInfo> selectHealthUserInfoList(HealthUserInfo healthUserInfo)
    {
        return healthUserInfoMapper.selectHealthUserInfoList(healthUserInfo);
    }

    /**
     * 新增提报人员信息
     * 
     * @param healthUserInfo 提报人员信息
     * @return 结果
     */
    @Override
    public int insertHealthUserInfo(HealthUserInfo healthUserInfo)
    {
    	String id = UUID.randomUUID().toString();
    	healthUserInfo.setId(id);
    	Date date = new Date();
    	healthUserInfo.setLastReportDate(date);
        return healthUserInfoMapper.insertHealthUserInfo(healthUserInfo);
    }

    /**
     * 修改提报人员信息
     * 
     * @param healthUserInfo 提报人员信息
     * @return 结果
     */
    @Override
    public int updateHealthUserInfo(HealthUserInfo healthUserInfo)
    {
    	Date date = new Date();
    	healthUserInfo.setLastReportDate(date);
        return healthUserInfoMapper.updateHealthUserInfo(healthUserInfo);
    }

    /**
     * 删除提报人员信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteHealthUserInfoByIds(String ids)
    {
        return healthUserInfoMapper.deleteHealthUserInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除提报人员信息信息
     * 
     * @param id 提报人员信息ID
     * @return 结果
     */
    @Override
    public int deleteHealthUserInfoById(String id)
    {
        return healthUserInfoMapper.deleteHealthUserInfoById(id);
    }

    /**
     * 根据手机号查询用户
     * 
     */
	@Override
	public HealthUserInfo queryUserByMobile(String userMobile) {
		HealthUserInfo healthUserInfo = new HealthUserInfo();
		healthUserInfo.setUserMobile(userMobile);
		return healthUserInfoMapper.queryUserByMobile(healthUserInfo);	
	}

	/**
	 * 根据手机号修改
	 * 
	 */
	@Override
	public int updateHealthUserInfoByMobile(HealthUserInfo healthUserInfo) {
		return healthUserInfoMapper.updateHealthUserInfoByMobile(healthUserInfo);
	}
}
